% Estimate ratio of 4 most frequent data in a frame.
% Return: Frequency of top 4 colors
% Arguments:
%   data = RGB representation of the frame
function [fre] = FreTop4(data)
    % Quantize the color
    [quan, map] = rgb2ind(data,256);

    % Get frequency histogram
    f = imhist(quan(:),256);

    % Sort f in desceding order to find the most frequent colors
    f = sort(f,'descend');
    fre = (f(1,1) + f(2,1) + f(3,1) + f(4,1))/sum(f);
end
